Skip to content

Fix read-only filesystem errors in check_workflow_recompile_needed tests#9979

Merged
pelikhan merged 3 commits into
mainfrom
copilot/fix-js-test-failures-ci
Jan 14, 2026
Merged

Fix read-only filesystem errors in check_workflow_recompile_needed tests#9979
pelikhan merged 3 commits into
mainfrom
copilot/fix-js-test-failures-ci

Conversation

Copilot AI commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Tests for check_workflow_recompile_needed failed in CI with EROFS: read-only file system when attempting to write template files to /opt/gh-aw/prompts/. The hardcoded path caused 4 test failures in CI Run #29542.

Changes

  • Added GH_AW_PROMPTS_DIR environment variable to make template path configurable

    • Defaults to /opt/gh-aw/prompts (backward compatible)
    • Tests override to use os.tmpdir() for isolation
  • Updated test cleanup to use fs.rmSync() instead of fs.unlinkSync()

    • Removes entire test directory tree
    • Properly restores environment variable state

Example

// Production: uses default path
const promptsDir = process.env.GH_AW_PROMPTS_DIR || "/opt/gh-aw/prompts";
const templatePath = `${promptsDir}/workflow_recompile_issue.md`;

// Tests: override with temp directory
process.env.GH_AW_PROMPTS_DIR = path.join(os.tmpdir(), "gh-aw-test", "prompts");

Other Reported Issues

The other 44 failures mentioned in CI Run #29542 (collect_ndjson_output and safe_outputs_mcp_server_defaults) are not reproducible in the current codebase—all 109 tests pass without modification.

Original prompt

This section details on the original issue you should resolve

<issue_title>[CI Failure Doctor] JS Test Failures - 46 Tests Failing in CI Environment (Run #29542)</issue_title>
<issue_description># 🏥 CI Failure Investigation - Run #29542

Summary

The CI workflow failed with 46 JavaScript test failures across 4 test files in the js job. The failure is NOT caused by code changes in PR #9954 (which only adds documentation), but exposes pre-existing test environment issues.

Failure Details

  • Run: #20997451868
  • Commit: efad162
  • Trigger: push (main branch)
  • Duration: 5m47s
  • Failed Job: js (step 7: Run tests)

Root Cause Analysis

🔴 Primary Issue: Read-Only Filesystem (4 failures)

File: check_workflow_recompile_needed.test.cjs
Error: EROFS: read-only file system, open '/opt/gh-aw/prompts/workflow_recompile_issue.md'

Root Cause: Tests attempt to write template files to /opt/gh-aw/prompts/ which is read-only in CI. The CI workflow's "Setup prompt templates for tests" step copies files to this location but doesn't make it writable.

Impact: All 4 tests in this file fail during setup and teardown.

🟡 Secondary Issue: Empty Output Validation (38 failures)

File: collect_ndjson_output.test.cjs
Error: expected [] to have a length of X but got +0

Root Cause: Tests expect parsedOutput.items to contain validation results, but receiving empty arrays. This suggests validation logic changed without updating tests.

Example failing tests:

  • should validate required fields for add-labels type
  • should validate required fields for create-pull-request type
  • should respect max limits from config
  • All JSON repair functionality tests
  • All code scanning alert validation tests

🟢 Tertiary Issue: MCP Server Timeouts (2 failures)

File: safe_outputs_mcp_server_defaults.test.cjs
Error: Test timed out in 10000ms

Tests:

  • should have optional branch parameter for create_pull_request
  • should have optional branch parameter for push_to_pull_request_branch

Test Summary

  • Test Files: 4 failed | 130 passed (134 total)
  • Tests: 46 failed | 2619 passed | 12 skipped (2677 total)
  • Duration: 75.69s

Investigation Findings

Important Context

PR #9954 only adds documentation - it creates a new file docs/src/content/docs/setup/cli.md with 490 lines of CLI documentation. No changes to JavaScript code or tests.

This means: The test failures are pre-existing issues that were exposed by this CI run, not introduced by the PR.

Reproduction Steps

cd actions/setup/js
npm ci
npm test
# Observe 46 test failures

Recommended Actions

🔴 HIGH PRIORITY - Fix Filesystem Issue

File: actions/setup/js/check_workflow_recompile_needed.test.cjs

Replace hardcoded /opt/gh-aw/prompts/ path with temp directory:

import os from 'os';
import path from 'path';

// BEFORE (line 12)
const templatePath = "/opt/gh-aw/prompts/workflow_recompile_issue.md";

// AFTER
const templatePath = path.join(os.tmpdir(), 'gh-aw-test', 'workflow_recompile_issue.md');

Alternative: Make /opt/gh-aw/prompts writable in CI:

- name: Setup prompt templates for tests
  run: |
    sudo mkdir -p /opt/gh-aw/prompts
    sudo chmod 777 /opt/gh-aw/prompts
    cp actions/setup/md/*.md /opt/gh-aw/prompts/

🟡 MEDIUM PRIORITY - Fix Validation Tests

File: actions/setup/js/collect_ndjson_output.test.cjs

Investigate why parsedOutput.items is empty:

  1. Check if safe output type registration changed
  2. Verify test data format matches current validation logic
  3. Update test expectations if validation behavior changed
  4. Add debug logging to see what's being parsed

🟢 LOW PRIORITY - Fix MCP Server Tests

File: actions/setup/js/safe_outputs_mcp_server_defaults.test.cjs

Increase timeout from 10000ms to 30000ms or add server startup verification.

Prevention Strategies

Pre-Commit Checklist

cd actions/setup/js
npm ci          # Install dependencies
npm test        # MUST pass before commit

Test Writing Rules

  1. ✅ Use os.tmpdir() for temp files, never /opt/ or /var/
  2. ✅ Mock file system operations when possible
  3. ✅ Use test fixtures instead of runtime file creation
  4. ❌ Never assume /opt/ directories are writable in CI
  5. ❌ Never skip test runs before committing

Example Pattern

// ❌ BAD - hardcoded system path
const templatePath = '/opt/gh-aw/prompts/template.md';

// ✅ GOOD - temp directory
import os from 'os';
import path from 'path';
const templatePath = path.join(os.tmpdir(), 'gh-aw-test', 'template.md');

AI Team Self-Improvement

Add to AI agent instructions:

## JavaScript Test Requirements

**ALWAYS run npm test before com...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes githubnext/gh-aw#9965

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/githubnext/gh-aw/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 14, 2026 16:02
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
- Add GH_AW_PROMPTS_DIR environment variable to make template path configurable
- Update test to use os.tmpdir() instead of hardcoded /opt/gh-aw/prompts
- Default to /opt/gh-aw/prompts for production (backward compatible)
- Tests now pass in both local and CI environments

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI failures caused by read-only filesystem Fix read-only filesystem errors in check_workflow_recompile_needed tests Jan 14, 2026
Copilot AI requested a review from mnkiefer January 14, 2026 16:12
@pelikhan pelikhan marked this pull request as ready for review January 14, 2026 22:48
@pelikhan pelikhan merged commit 04dcdf2 into main Jan 14, 2026
@pelikhan pelikhan deleted the copilot/fix-js-test-failures-ci branch January 14, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants